import requests
import datetime


def login():
    headers = {
        'Accept': 'application/json, text/plain, */*',
        'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
        'Connection': 'keep-alive',
        'Content-Type': 'application/json;charset=UTF-8',
        'Origin': 'http://newcrm-dev1.hotmaxx.cn',
        'Referer': 'http://newcrm-dev1.hotmaxx.cn/',
        'Sec-Fetch-Dest': 'empty',
        'Sec-Fetch-Mode': 'cors',
        'Sec-Fetch-Site': 'cross-site',
        'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36',
        'X-PlatformId': '1',
        'sec-ch-ua': '"Chromium";v="106", "Google Chrome";v="106", "Not;A=Brand";v="99"',
        'sec-ch-ua-mobile': '?0',
        'sec-ch-ua-platform': '"macOS"',
    }

    json_data = {
        'phone': '17621455198',
        'captchaId': 'captcha_idbeos6HauWH',
        'captcha': '',
        'code': '666666',
        'platformId': 1,
    }

    response = requests.post('https://gateway-dev.hotmaxx.cn/user/user/login', headers=headers, json=json_data, timeout=0.1)
    return response.json()['data']["accessToken"]


def query_order(checkType,type=1):
    headers = {
        'Authorization': f'Bearer {login()}',
        'Content-Type': 'application/json;charset=UTF-8',
        'X-PlatformId': '1'
    }

    json_data = {"page": 1, "pageSize": 20, "effectTime": ["2024-07-09", "2024-07-09"], "type": type, "checkType": checkType}
    response = requests.post('https://gateway-dev.hotmaxx.cn/goods-server/pricesys/adjustPriceList', headers=headers,
                             json=json_data)
    return response.json()




print(login())